package com.mygame.center.config;

import com.ecwid.consul.v1.ConsulClient;
import com.ecwid.consul.v1.ConsulRawClient;
import com.mygame.common.natsConfig.NatsListener;
import io.nats.client.Nats;
import io.nats.streaming.StreamingConnection;
import io.nats.streaming.StreamingConnectionFactory;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.consul.discovery.ConsulDiscoveryClient;
import org.springframework.cloud.consul.discovery.ConsulDiscoveryProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Role;
import org.springframework.core.annotation.Order;

import java.io.IOException;
import java.time.Duration;
import java.util.UUID;

/**
 * @author wanli
 * @date 2018-09-17
 */
@Configuration
@Order(1)
public class ConsulConfiguration {
    @Bean
    public ConsulDiscoveryClient discoveryClient(ConsulDiscoveryProperties properties) {
        ConsulRawClient rawClient = new ConsulRawClient();
        ConsulClient client = new ConsulClient(rawClient);
        return new ConsulDiscoveryClient(client, properties);
    }

}
